require('dotenv').config();

const express = require("express");
const bodyParser = require('body-parser');
const path = require("path")
const cors = require("cors")
const app = express()
const port = 3001

app.use(cors({
    origin: true,
    credentials: true,
    allowedHeaders: ['Content-Type', 'Authorization', 'token', 'Token'],
    exposedHeaders: ['token', 'Token']
}))

app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())

app.use("/static", express.static(path.resolve(__dirname, "public")))
app.use("/admin", express.static(path.resolve(__dirname, "admin")))

app.use('/api/banner', require("./router/banner.js"))
app.use('/api/cate', require("./router/cate.js"))
app.use('/api/user', require("./router/user.js"))
app.use('/api/article', require("./router/article.js"))
app.use('/api/admin', require("./router/admin.js"))
app.use('/api/photo', require("./router/photo.js"))
app.use('/api/statistics', require("./router/statistics.js"))
app.use('/api/operationLog', require("./router/operationLog.js"))
app.use('/api/comment', require("./router/comment.js"))
app.use('/api/favorite', require("./router/favorite.js"))
app.use('/api/danmu', require("./router/danmu.js"))


app.listen(port, () => {
    console.log("http 启动成功 ~~", port)
})
